<!--
* @description 附近监控
* @author zywu
* @date 2021/04/29 14:58:11
!-->
<template>
  <el-table :data="deviceList" :height="height">
    <el-table-column prop="name" label="名称" align="center" show-overflow-tooltip></el-table-column>
    <el-table-column label="操作" align="center">
      <template slot-scope="scope">
        <el-button @click="openMonitor(scope.row)" type="text" size="small">查看监控</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import util from '@/utils/util'
import { getFcfStatusList } from '@/api/fcf'
export default {
  props: {
    height: {
      type: Number,
      default: 458,
    },
    dataObj: {
      type: Object,
      default: function () {
        return {}
      },
    },
  },
  data() {
    return {
      deviceList: [],
    }
  },

  components: {},

  computed: {},

  created() {
    this.getFcfStatusList()
  },

  mounted() {},

  methods: {
    // 打开附件的监控
    openMonitor(videoItem) {
      let row = videoItem.deviceItem
      util.rowShowVedio(
        {
          fcFacilitiesId: row.id,
          organizationId: row.organizationId,
          serverId: row.serverId,
        },
        0,
        videoItem
      )
    },
    getFcfStatusList() {
      getFcfStatusList({
        orgIds: this.dataObj.unitId,
        fbsId: 0,
        systemId: '-1',
        fcfCategoryId: '',
        fireTType: '-1',
        pageSize: 10,
        queryType: 0,
      }).then((res) => {
        let list = []
        let ids = []
        res.data.forEach((n) => {
          if (n.videoList) {
            n.videoList.forEach((m) => {
              if (ids.indexOf(m.id) < 0) {
                m.deviceItem = {
                  ...n,
                  videoList: [],
                }
                ids.push(m.id)
                list.push(m)
              }
            })
          }
        })
        this.deviceList = list
      })
    },
  },
}
</script>
<style lang='scss'>
</style>